home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6807 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c,comp.graphics.algorithms,rec.games.programmer
  4. Subject: Re: Speed question here...
  5. Date: 15 Feb 1996 10:17:25 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4fv17l$o23@sparcserver.lrz-muenchen.de>
  9. References: <4ftluh$1gkv@hearst.cac.psu.edu>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. koscho@wjk130.rh.psu.edu (William Koscho) writes:
  13.  
  14. >I was curious as to how fast something like the 
  15. >following would execute:
  16.  
  17. >    int x;
  18. >    node *ptr;   ptr in linked list
  19.  
  20. >       for ( ptr = first_node; ptr != NULL; ptr = ptr.next ) {
  21. >       for ( x = 0; x < max; x++ ) {
  22. >        array[x] = array_other[x];
  23. >           }
  24. >      } 
  25.  
  26. >I really am not interested in the assignment statement, that's easy.
  27. >but the traversal through the linked list, and inner integer incremental
  28. >for loop for each node visited.  How fast is a traversal through
  29. >a linked list when you do a for loop at each node?
  30.  
  31. 1) Since this code cannot be compiled, discussions about it's execution
  32.    speed are not very meaningful.
  33.  
  34. 2) Compile the code for your target machine, using your target compiler.
  35.    Then time it on your target machine. The C programming language does
  36.    not enforce certain optimaization techniques, even if some of them
  37.    are easier for C programs, while others are more difficult.
  38.  
  39. Kurt
  40. --
  41. | Kurt Watzka                             Phone : +49-89-2180-6254
  42. | watzka@stat.uni-muenchen.de
  43. | ua302aa@sunmail.lrz-muenchen.de
  44.  
  45.